1 <%@ Application Language="C#" %>
2
3 <script runat=
"server">
4     
string s;
5     
int sltructuyen = 0;
6     
void Application_Start(object sender, EventArgs e)
7     {
8         
// Code that runs on application startup
9         Application.Lock();
10         System.IO.StreamReader sr;
11         sr =
new System.IO.StreamReader(Server.MapPath("App_Data/sl.txt"));
12         s = sr.ReadLine();
13         sr.Close();
14         
//sr1 = new System.IO.StreamReader(Server.MapPath("App_Data/tt.txt"));
15         
//s1 = sr1.ReadLine();
16         Application.UnLock();
17         Application.Add(
"sltruycap", s);
18         Application.Add(
"sltructuyen", sltructuyen);
19     }
20     
21     
void Application_End(object sender, EventArgs e)
22     {
23         
// Code that runs on application shutdown
24         Application.Contents[
"sltructuyen"] = 0;
25         
//System.IO.StreamWriter sw3;
26         
//sw3 = new System.IO.StreamWriter(Server.MapPath("App_Data/tt.txt"));
27         
//sw3.Write(Application.Contents["sltructuyen"].ToString());
28         
//sw3.Close();
29     }
30         
31     
void Application_Error(object sender, EventArgs e)
32     {
33         
// Code that runs when an unhandled error occurs
34        
35     }
36
37     
void Session_Start(object sender, EventArgs e)
38     {
39         
40         
// Code that runs when a new session is started
41         Application.Contents[
"sltruycap"] = int.Parse(Application.Contents["sltruycap"].ToString()) + 1;
42         sltructuyen =
int.Parse( Application.Contents["sltructuyen"].ToString())+1;
43         System.IO.StreamWriter sw;
44         sw =
new System.IO.StreamWriter(Server.MapPath("App_Data/sl.txt"));
45         sw.Write(Application.Contents[
"sltruycap"].ToString());
46         Application.Contents[
"sltructuyen"] = sltructuyen;
47         
//sw1 = new System.IO.StreamWriter(Server.MapPath("App_Data/tt.txt"));
48         
//sw1.Write(Application.Contents["sltructuyen"].ToString());
49         sw.Close();
50         
//sw1.Close();
51     }
52
53     
void Session_End(object sender, EventArgs e)
54     {
55         
// Code that runs when a session ends.
56         
// Note: The Session_End event is raised only when the sessionstate mode
57         
// is set to InProc in the Web.config file. If session mode is set to StateServer
58         
// or SQLServer, the event is not raised.
59        sltructuyen=
int.Parse(Application.Contents["sltructuyen"].ToString())- 1;
60        Application.Contents[
"sltructuyen"] = sltructuyen;
61     }
62        
63 </script>



Quản lý website giới thiệu và bán điện thoại di động ASP.net 19.307 lượt xem

Gõ tìm kiếm nhanh...